package com.biao.java8.method_reference;

public class Test04_object_main {
    public static void main(String[] args) {
        /*
        对象方法引入
         */

        // 匿名内部类方式
        Test04_object test04Object = new Test04_object() {
            @Override
            public String get(Test04_object_main test04ObjectMain) {
                return test04ObjectMain.objectTest();
            }
        };
        System.out.println(test04Object.get(new Test04_object_main()));

        // lambda方式
        Test04_object test04Object2 = (a) -> a.objectTest();
        System.out.println(test04Object2.get(new Test04_object_main()));

        // 对象方法引入
        /*
        Test04_object 接口中的抽象方法返回值是 String， objectTest 方法的返回值也是 String，
        所以返回的就是 objectTest 方法调用的意思
         */
        Test04_object test04Object3 = Test04_object_main::objectTest;
        System.out.println(test04Object3.get(new Test04_object_main()));

    }

    public String objectTest() {
        return "objectTest...";
    }
}
